package main

import(
	"context"
	"fmt"
	"goTestToMod/grpc/proto"
	"google.golang.org/grpc"
	"net"
)

type Server struct {
}

func (this *Server) Hello (ctx context.Context, helloReq *proto.HelloRequse) (*proto.Respons, error) {
	return &proto.Respons{
		Reply: fmt.Sprintf("hellow %s", helloReq.Name),
	}, nil
}

func main (){
	g := grpc.NewServer()
	proto.RegisterHelloServer(g, &Server{})
	lis, err := net.Listen("tcp", "0.0.0.0:8021")
	if err != nil {
		fmt.Println(err.Error())
		panic("启动服务失败")
	}
	err = g.Serve(lis)
	if err != nil {
		panic("grpc 启动失败")
	}
}